package com.ag.improvedjava.iterable;

import java.util.Iterator;
import java.util.LinkedList;

final class ReverseIterable<T> implements Iterable<T> {

	private Iterable<T> iterable;
	
	ReverseIterable(Iterable<T> iterable) {
		this.iterable = iterable;
	}

	@Override
	public Iterator<T> iterator() {
		LinkedList<T> stack = new LinkedList<T>();
		for (T t : iterable) {
			stack.push(t);
		}
		return stack.iterator();
	}
}
